<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/head.ftl"/>

    <script>
        $(function () {
            $(".btn-input").click(function () {

                //清除模态框的数据
                $("#inputModal").clearForm();
                var json = $(this).data("json");
                //console.log(json);
                if (json){
                    $("#editForm input[name='id']").val(json.id);
                    $("#editForm input[name='name']").val(json.name);
                    $("#editForm input[name='strategy.id']").val(json.strategyId);
                    $("#editForm input[name='sequence']").val(json.sequence);
                    $("#editForm select[name='state']").val(json.state +"");
                }

                $("#inputModal").modal("show");

                //在模态框里面提交表单
                $("#save").click(function () {
                    $("#editForm").ajaxSubmit();
                })
            })
        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#assign menu="strategyCatalog"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">攻略分类管理</h1>
                </div>
            </div>
            <!--高级查询--->

            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/strategyCatalog/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                        <label >攻略搜索</label>
                        <select id="strategySelect" name="strategyId" class="form-control form-control-chosen" data-placeholder="请选择所属攻略" >
                            <option value="-1">全部攻略</option>
                            <#list strategies as st>
                                <option value="${st.id}">${st.title}</option>
                            </#list>
                        </select>
                    </div>
                    <div class="form-group">
                        <button id="query"<#-- type="button"--> class="btn btn-success"><i class="icon-search"></i> 查询</button>
                        <a href="javascript:;" class="btn btn-success btn-input" id="addStrategyCatalogBtn">添加攻略分类</a>
                    </div>
                </form>

            </div>

            <table class="table table-striped table-hover">
                <tr>
                    <th>分类名称</th>
                    <th>所属攻略</th>
                    <th>排序</th>
                    <th>状态</th>
                    <th></th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${(entity.name)!}</td>
                        <td>${(entity.strategy.title)!}</td>
                        <td>${(entity.sequence)!}</td>
                        <td>${(entity.stateDisplay)!}</td>
                        <td><a href="javascript:;" class="btn-input" data-json='${entity.jsonString}'>修改</a></td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>



<!-- 模态框（Modal） -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">编辑/添加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyCatalog/saveOrUpdate.do" method="post" id="editForm"
                      enctype="multipart/form-data">
                    <input type="hidden" name="id">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">分类名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-4 control-label">所属攻略：</label>
                        <div class="col-sm-6">
                            <select  class="form-control" name="strategy.id">
                            <#list strategies as st>
                                <option value="${st.id}">${st.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">排序：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sequence">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="state">
                                <option value="">---请选择---</option>
                                <option value="true">正常</option>
                                <option value="false">禁用</option>
                            </select>

                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-save" id="save">保存</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>